package com.poetize.plus.entity.dto;

import com.poetize.plus.entity.po.User;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

/**
 * @author zuosy
 * @created 2024/5/17 16:07
 */
public record UserUiDTO(
        @Schema(description = "ID")
        @NotNull(message = "ID不能为空")
        Long id,

        @Schema(description = "头像")
        String avatar,

        @Schema(description = "邮箱")
        @NotNull(message = "邮箱不能为空")
        String email,

        @Schema(description = "性别")
        String gender,
        @Schema(description = "简介")
        String introduction
) {

    /**
     * DTO转PO
     *
     * @param userUiDTO
     * @return
     */
    public static User convertDTO(UserUiDTO userUiDTO) {
        return new User(userUiDTO.id, userUiDTO.email, userUiDTO.gender, userUiDTO.avatar, userUiDTO.introduction);
    }
}
